from time import sleep

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC


class Mytest:
    def __init__(self, testUrl, searchText):
        self.testUrl = testUrl
        self.searchText = searchText


    def baiduSearch(self):
        self.driver = webdriver.Chrome()
        self.driver.get(self.testUrl)
        input = WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located((By.ID,'kw')))
        input.send_keys(self.searchText)
        self.driver.find_element(By.ID,'su').click()
        sleep(2)
        wendu=self.driver.find_element(By.XPATH,"//div[@class='weather-main_lecpj cu-color-white']/div/span")
        print("长沙温度："+wendu.text)


   # def validateSearchReslut(self):
